package com.andy.utils.excel.beesxicircle0613.temp;

import lombok.Getter;

import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;

/**
 * @author houfeixia
 * @date 2022/3/8 14:04
 */
@Getter
public enum BeesIsalesPocStatusCodeEnum {

    IMPORT(1, "已导入", 1, "待确认", false),
    REGISTER(2, "注册中", 2, "已邀请", false),
    REGISTER_FEEDBACK(3, "注册中-邀请反馈", 3, "待修改", false),
    NOT_AUDIT_REGISTER(4, "注册待审核", 4, "待审核", false),
    NOT_AUDIT_MODIFY(5, "修改资料待审核", 4, "待审核", true),
    AGREE_REGISTER(6, "注册已审核通过", 5, "已审核通过", true),
    AGREE_MODIFY(7, "修改资料已审核通过", 5, "已审核通过", true),
    REFUSE_REGISTER(8, "注册审核未通过", 6, "审核未通过", false),
    REFUSE_MODIFY(9, "修改资料审核未通过", 6, "审核未通过", true),
    FORBID(10, "已冻结", 7, "已冻结", false),
    CLOSE(11, " 已关闭", 8, "已关闭", false),
    CONFIRM(12, "待确认", 1, "待确认", false),
    INVITED(2, "已邀请", 2, "已邀请", false),
    CONFIRM_PASS(13, "确认", 2, "已邀请", false),
    TO_MODIFY(14, "待修改", 3, "待修改", false);
    private final Integer beesCode;
    private final String beesName;
    private final Integer iSalesCode;
    private final String iSalesName;
    private final Boolean icon;

    BeesIsalesPocStatusCodeEnum(Integer beesCode, String beesName, Integer iSalesCode, String iSalesName, Boolean icon) {
        this.beesCode = beesCode;
        this.beesName = beesName;
        this.iSalesCode = iSalesCode;
        this.iSalesName = iSalesName;
        this.icon = icon;
    }

    private static final Set<BeesIsalesPocStatusCodeEnum> ALL = EnumSet.allOf(BeesIsalesPocStatusCodeEnum.class);


    public static Boolean getIcon(Integer beesCode) {
        return ALL.stream()
                .filter(o -> Objects.equals(o.beesCode, beesCode))
                .map(BeesIsalesPocStatusCodeEnum::getIcon)
                .findAny().orElse(null);
    }

    public static String getISalesName(Integer beesCode) {
        return ALL.stream()
                .filter(o -> Objects.equals(o.beesCode, beesCode))
                .map(BeesIsalesPocStatusCodeEnum::getISalesName)
                .findAny().orElse(null);
    }

    public static Integer getISalesCode(Integer beesCode) {
        return ALL.stream()
                .filter(o -> Objects.equals(o.beesCode, beesCode))
                .map(BeesIsalesPocStatusCodeEnum::getISalesCode)
                .findAny().orElse(null);
    }

    public static Integer getISalesCode(Integer beesCode, Integer channelCheckStatus, Integer confirmStatus) {
        /**
         * beesCode(bees主状态)
         * channelCheckStatus(渠道变更申请状态：0-无，1-待审核，2-审批通过，3-审批拒绝)
         * confirmStatus(M1确认状态 1待确认 2通过 3失败 4待审核)
         * bees主状态为通过前提下
         * channelCheckStatus为3表示修改资料未通过，即isales状态的审核未通过
         * channelCheckStatus为1,若confirmStatus为1或者4表示待确认，若confirmStatus不为1或者4则表示待修改
         */
        if (Objects.equals(6, beesCode)) {
            if (Objects.equals(3, channelCheckStatus)) {
                return REFUSE_MODIFY.getISalesCode();
            }
            if (Objects.equals(1, channelCheckStatus)) {
                if (Objects.equals(1, confirmStatus) || Objects.equals(4, confirmStatus)) {
                    return CONFIRM.getISalesCode();
                } else {
                    return NOT_AUDIT_MODIFY.getISalesCode();
                }
            }
        }
        return ALL.stream()
                .filter(o -> Objects.equals(o.beesCode, beesCode))
                .map(BeesIsalesPocStatusCodeEnum::getISalesCode)
                .findAny().orElse(null);
    }

}


